<?php

class AccessFilter extends CFilter
{
    /**
     * @param CFilterChain $filterChain the filter chain that the filter is on.
     * @return boolean
     * @throw CHttpException
     */
    public function preFilter($filterChain)
    {
        $loginRequired = !Yii::app()->controller->checkUserToken($_POST['user_id'],TOKEN);
        if(!$loginRequired)
            return true;
        $data = array(
            'success' => 0,
            'action'  => 'login',
            'code'    => -1,
            'message' => '请重新登录',
        );
        echo json_encode($data);
        Yii::app()->end();
    }
}
